<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Código-Fonte de mutate_bit_by_bit.h</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Gerado por Doxygen 1.6.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Busca');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Página&nbsp;Principal</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Arquivos</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <img id="MSearchSelect" src="search/search.png"
             onmouseover="return searchBox.OnSearchSelectShow()"
             onmouseout="return searchBox.OnSearchSelectHide()"
             alt=""/>
        <input type="text" id="MSearchField" value="Busca" accesskey="S"
             onfocus="searchBox.OnSearchFieldFocus(true)" 
             onblur="searchBox.OnSearchFieldFocus(false)" 
             onkeyup="searchBox.OnSearchFieldChange(event)"/>
        <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>Lista&nbsp;de&nbsp;Arquivos</span></a></li>
      <li><a href="globals.html"><span>Arquivos&nbsp;Membros</span></a></li>
    </ul>
  </div>
<h1>mutate_bit_by_bit.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef MUTATE_BIT_BY_BIT_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define MUTATE_BIT_BY_BIT_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="preprocessor">#include &quot;<a class="code" href="genetic__operator_8h.html">genetic_operator.h</a>&quot;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &quot;<a class="code" href="definitions_8h.html">definitions.h</a>&quot;</span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty = GAtype,<span class="keyword">typename</span> _realTy = GAreal_type&gt; <span class="keyword">class </span><a class="code" href="classmutate__bit__by__bit.html">mutate_bit_by_bit</a>;
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00012"></a><a class="code" href="classmutate__bit__by__bit.html">00012</a> <span class="keyword">class </span><a class="code" href="classmutate__bit__by__bit.html">mutate_bit_by_bit</a> : <span class="keyword">public</span> <a class="code" href="classgenetic__operator.html">genetic_operator</a>&lt;_ty,_realTy&gt;
<a name="l00013"></a>00013 {
<a name="l00014"></a>00014   <span class="keyword">public</span>:
<a name="l00015"></a>00015 
<a name="l00016"></a>00016     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00023"></a>00023     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00024"></a><a class="code" href="classmutate__bit__by__bit.html#a14de7465518021a37cfa7e06e19d02f5">00024</a>     <a class="code" href="classmutate__bit__by__bit.html#a14de7465518021a37cfa7e06e19d02f5">mutate_bit_by_bit</a> (<a class="code" href="classpopulation.html">population&lt;_ty,_realTy&gt;</a>* pt_to_apply_operator = NULL,
<a name="l00025"></a>00025                        <span class="keyword">const</span> <span class="keywordtype">float</span>&amp; probability = def::genetic_operator::mutate_bit_by_bit::probability)
<a name="l00026"></a>00026                        :<a class="code" href="classgenetic__operator.html">genetic_operator</a>&lt;_ty,_realTy&gt;::<a class="code" href="classgenetic__operator.html">genetic_operator</a>(pt_to_apply_operator,probability){}
<a name="l00027"></a>00027 
<a name="l00028"></a>00028     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00036"></a>00036     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00037"></a><a class="code" href="classmutate__bit__by__bit.html#a2f8cc52a35943854f24b7534ecd90c7b">00037</a>     <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>&amp; <a class="code" href="classmutate__bit__by__bit.html#a2f8cc52a35943854f24b7534ecd90c7b">WalkOnPopulationHook</a> (<a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>&amp; <span class="keywordtype">id</span> ){<span class="keywordflow">return</span> def::genetic_operator::go_down;}
<a name="l00038"></a>00038 
<a name="l00039"></a>00039     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00047"></a>00047     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00048"></a>00048     <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>&amp; <a class="code" href="classmutate__bit__by__bit.html#a150b01e7ee79683012f7d60e8c1b9ccc">WalkOnIndividualHook</a> (<a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>&amp; coo);
<a name="l00049"></a>00049 
<a name="l00050"></a>00050     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00056"></a>00056     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00057"></a><a class="code" href="classmutate__bit__by__bit.html#abdab6da2a2b180f14d71f35c895313a4">00057</a>     <span class="keyword">virtual</span> std::string <a class="code" href="classmutate__bit__by__bit.html#abdab6da2a2b180f14d71f35c895313a4">GetName</a> (<span class="keywordtype">void</span>) {<span class="keywordflow">return</span> (<a class="code" href="classgenetic__operator.html">genetic_operator&lt;_ty,_realTy&gt;::GetName</a>()+ <span class="stringliteral">&quot;-&gt;&quot;</span> + <span class="stringliteral">&quot;mutate_bit_by_bit&quot;</span>);}
<a name="l00058"></a>00058 
<a name="l00059"></a>00059 };
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00062"></a><a class="code" href="classmutate__bit__by__bit.html#a150b01e7ee79683012f7d60e8c1b9ccc">00062</a> <span class="keyword">const</span> <span class="keywordtype">char</span>&amp; <a class="code" href="classmutate__bit__by__bit.html#a150b01e7ee79683012f7d60e8c1b9ccc">mutate_bit_by_bit&lt;_ty,_realTy&gt;::WalkOnIndividualHook</a> (<a class="code" href="classcoordinate.html">coordinate&lt;_ty,_realTy&gt;</a>&amp; coo)
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064   <span class="keywordtype">int</span> size = coo.<a class="code" href="classcoordinate.html#a0e3450e6a6a1b4d577886fb68883d61c">GetSize</a>();
<a name="l00065"></a>00065   <span class="keywordtype">int</span> mask_1 = 1;
<a name="l00066"></a>00066   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i != size; ++i)
<a name="l00067"></a>00067   {
<a name="l00068"></a>00068 
<a name="l00069"></a>00069     <span class="keywordflow">if</span> (<a class="code" href="classgenetic__operator.html">genetic_operator&lt;_ty,_realTy&gt;::GenerateRandom</a>()&lt;<a class="code" href="classgenetic__operator.html">genetic_operator&lt;_ty,_realTy&gt;::_probability</a>)
<a name="l00070"></a>00070     {
<a name="l00071"></a>00071       <span class="keywordtype">int</span> mask_2 = coo.<a class="code" href="classcoordinate.html#a67e7c384fd0641455b6629a7d6a9a344">GetValue</a>() &amp; mask_1;
<a name="l00072"></a>00072       <span class="keywordflow">if</span> (mask_2)
<a name="l00073"></a>00073        coo.<a class="code" href="classcoordinate.html#ae66e44d1146ca8020809efe799a5a59c">SetValue</a>(coo.<a class="code" href="classcoordinate.html#a67e7c384fd0641455b6629a7d6a9a344">GetValue</a>() - mask_1);
<a name="l00074"></a>00074       <span class="keywordflow">else</span>
<a name="l00075"></a>00075         coo.<a class="code" href="classcoordinate.html#ae66e44d1146ca8020809efe799a5a59c">SetValue</a>(coo.<a class="code" href="classcoordinate.html#a67e7c384fd0641455b6629a7d6a9a344">GetValue</a>() + mask_1);
<a name="l00076"></a>00076     }
<a name="l00077"></a>00077     mask_1 = mask_1 &lt;&lt; 1;
<a name="l00078"></a>00078   }
<a name="l00079"></a>00079   <span class="keywordflow">return</span> def::genetic_operator::go_forward;
<a name="l00080"></a>00080 }
<a name="l00081"></a>00081 
<a name="l00082"></a>00082 <span class="preprocessor">#endif //MUTATE_BIT_BY_BIT_H</span>
</pre></div></div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>Todos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Arquivos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Funções</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Variáveis</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Definições de Tipos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Amigas</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address style="text-align: right;"><small>Gerado em Sat Oct 30 13:47:50 2010 por&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
